﻿<%@ Page Title="Atualizar Fichas Financeiras" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="AtualizarFichaFinanceira.aspx.cs" Inherits="AcadPosApp.ControlarMatricula.AtualizarFichaFinanceira" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language="javascript" type="text/javascript">
        function SelecionaTodosChecks(spanChk) {

            var oItem = spanChk.children;

            var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];

            xState = theBox.checked;

            elm = theBox.form.elements;

            for (i = 0; i < elm.length; i++)

                if (elm[i].type == "checkbox" && elm[i].id != theBox.id) {
                    if (elm[i].checked != xState)

                        elm[i].click();
                }
        }

        function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e) {
            var sep = 0;
            var key = '';
            var i = j = 0;
            var len = len2 = 0;
            var strCheck = '0123456789';
            var aux = aux2 = '';
            var whichCode = (window.Event) ? e.which : e.keyCode;
            if (whichCode == 13) return true;
            key = String.fromCharCode(whichCode); // Valor para o código da Chave 
            if (strCheck.indexOf(key) == -1) return false; // Chave inválida 
            len = objTextBox.value.length;
            for (i = 0; i < len; i++)
                if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
            aux = '';
            for (; i < len; i++)
                if (strCheck.indexOf(objTextBox.value.charAt(i)) != -1) aux += objTextBox.value.charAt(i);
            aux += key;
            len = aux.length;
            if (len == 0) objTextBox.value = '';
            if (len == 1) objTextBox.value = '0' + SeparadorDecimal + '0' + aux;
            if (len == 2) objTextBox.value = '0' + SeparadorDecimal + aux;
            if (len > 2) {
                aux2 = '';
                for (j = 0, i = len - 3; i >= 0; i--) {
                    if (j == 3) {
                        aux2 += SeparadorMilesimo;
                        j = 0;
                    }
                    aux2 += aux.charAt(i);
                    j++;
                }
                objTextBox.value = '';
                len2 = aux2.length;
                for (i = len2 - 1; i >= 0; i--)
                    objTextBox.value += aux2.charAt(i);
                objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
            }
            return false;
        } 
    </script>
    <style type="text/css">
        .style1
        {
            width: 312px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Panel ID="pnlPesquisa" runat="server" GroupingText="Consulta de Alunos">
        <table class="form-inline">
            <tr>
                <td colspan="2">
                    <asp:Label ID="Label1" runat="server" Text="Estado"></asp:Label>
                    <br />
                    <asp:DropDownList ID="ddlEstadoPesquisa" runat="server" OnSelectedIndexChanged="ddlEstadoPesquisa_SelectedIndexChanged"
                        AutoPostBack="True" Width="150px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="Label2" runat="server" Text="Descrição"></asp:Label>
                    <br />
                    <asp:TextBox ID="TxtPesquisa" required pattern="[çÇùÙúÚôÔõÕòÒóÓìÌíÍêÊèÈéÉáÁàÀãÃâÂaA-zZ\s]+$"
                        title="Apenas Letras." runat="server" Width="300px" MaxLength="150"></asp:TextBox>
                </td>
                <td>
                    <br />
                    <asp:Button ID="btnConsultar" runat="server" Text="Consultar" 
                        OnClick="btnConsultar_Click" Width="100px" />
                </td>
            </tr>
        </table>
        <br />
        <asp:GridView ID="gvwPesquisa" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CssClass="mGrid" DataKeyNames="MATRICULA,CPF" EmptyDataText="Dados não localizados..."
            GridLines="Vertical" Width="45%" OnSelectedIndexChanged="gvwPesquisa_SelectedIndexChanged"
            OnPageIndexChanging="gvwPesquisa_PageIndexChanging">
            <AlternatingRowStyle BackColor="#D3D3D3" />
            <Columns>
                <asp:CommandField ButtonType="Image" SelectImageUrl="~/Imagens/select.png" ShowSelectButton="True" />
                <asp:BoundField DataField="MATRICULA" HeaderText="Matrícula">
                    <ItemStyle HorizontalAlign="Center" Width="10%" />
                </asp:BoundField>
                <asp:BoundField DataField="NOME" HeaderText="Nome">
                    <ItemStyle HorizontalAlign="Left" Width="90%" />
                </asp:BoundField>
            </Columns>
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#808080" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#383838" />
        </asp:GridView>
    </asp:Panel>
    <br />
    <asp:Panel ID="pnlMatriculasAluno" runat="server" GroupingText="Matrículas do Aluno"
            Visible="false">
            <asp:GridView ID="gvwMatriculasAluno" runat="server" AutoGenerateColumns="False"
                CssClass="mGrid" DataKeyNames="ID_MATRICULA, MATRICULA,ID_TURMA" EmptyDataText="Dados não localizados..."
                GridLines="Vertical" Width="65%" AllowPaging="True" OnPageIndexChanging="gvwMatriculasAluno_PageIndexChanging"
                OnSelectedIndexChanged="gvwMatriculasAluno_SelectedIndexChanged">
                <AlternatingRowStyle BackColor="#D3D3D3" />
                <Columns>
                    <asp:CommandField ButtonType="Image" SelectImageUrl="~/Imagens/select.png" ShowSelectButton="True" />
                    <asp:BoundField DataField="ID_CURSO" HeaderText="Código">
                        <HeaderStyle HorizontalAlign="Center" Width="1%" />
                        <ItemStyle HorizontalAlign="Center" Width="1%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="NOME_CURSO" HeaderText="Curso">
                        <HeaderStyle HorizontalAlign="Center" Width="30%" />
                        <ItemStyle HorizontalAlign="Left" Width="30%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="CURRICULO" HeaderText="Currículo">
                        <HeaderStyle HorizontalAlign="Center" Width="10%" />
                        <ItemStyle HorizontalAlign="Center" Width="10%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="NOME_MODULO" HeaderText="Módulo">
                        <HeaderStyle HorizontalAlign="Center" Width="30%" />
                        <ItemStyle HorizontalAlign="Left" Width="30%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="COD_TURMA" HeaderText="Turma">
                        <HeaderStyle HorizontalAlign="Center" Width="10%" />
                        <ItemStyle HorizontalAlign="Center" Width="10%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="ESTADO" HeaderText="Estado">
                        <HeaderStyle HorizontalAlign="Center" Width="1%" />
                        <ItemStyle HorizontalAlign="Left" Width="1%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="NOME_POLO" HeaderText="Polo">
                        <HeaderStyle HorizontalAlign="Center" Width="10%" />
                        <ItemStyle HorizontalAlign="Left" Width="10%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="DATA_MATRICULA" HeaderText="Dt.Matrícula">
                        <HeaderStyle HorizontalAlign="Center" Width="30%" />
                        <ItemStyle HorizontalAlign="Left" Width="30%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="SITUACAO" HeaderText="Situação">
                        <HeaderStyle HorizontalAlign="Center" Width="10%" />
                        <ItemStyle HorizontalAlign="Left" Width="10%" />
                    </asp:BoundField>
                </Columns>
                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#808080" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#383838" />
            </asp:GridView>
        </asp:Panel>
        <br />
    <asp:Panel ID="pnlFichaFinanceira" runat="server" GroupingText="Atualizar Ficha Financeira"
        Visible="False">
        <div style="height: 159px; width:960px; overflow: auto">
            <asp:GridView ID="gvwFinanceiroAluno" runat="server" AutoGenerateColumns="False"
                CssClass="mGrid" DataKeyNames="ID_FINANCEIRO,NOSSO_NUMERO" EmptyDataText="Dados não localizados..."
                GridLines="Vertical" Width="50%" OnPageIndexChanging="gvwFinanceiroAluno_PageIndexChanging"
                Visible="False" OnRowDataBound="gvwFinanceiroAluno_RowDataBound">
                <AlternatingRowStyle BackColor="#D3D3D3" />
                <Columns>
                    <asp:TemplateField>
                        <HeaderStyle Width="30px" HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" Font-Size="11px" Width="30px" />
                        <HeaderTemplate>
                            <asp:CheckBox ID="CheckAll" runat="server" onclick="javascript:SelecionaTodosChecks(this)" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" TextAlign="Left" HorizontalAlign="Center" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="PARCELA" HeaderText="Parcela">
                        <HeaderStyle HorizontalAlign="Center" Width="1%" />
                        <ItemStyle HorizontalAlign="Center" Width="1%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="VALOR" HeaderText="Valor" DataFormatString="{0:c}">
                        <HeaderStyle HorizontalAlign="Center" Width="20%" />
                        <ItemStyle HorizontalAlign="Center" Width="20%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="VALOR_AJUSTADO" HeaderText="Valor + Juros" DataFormatString="{0:c}">
                        <HeaderStyle HorizontalAlign="Center" Width="20%" />
                        <ItemStyle HorizontalAlign="Center" Width="20%" />
                    </asp:BoundField>
                    <%-- <asp:BoundField DataField="ANO" HeaderText="Ano">
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Left" Width="1%" />
                </asp:BoundField>--%>
                    <asp:BoundField DataField="DATA_VENCIMENTO" HeaderText="Data Vencimento">
                        <HeaderStyle HorizontalAlign="Center" Width="20%" />
                        <ItemStyle HorizontalAlign="Center" Width="20%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="DATA_PAGAMENTO" HeaderText="Data Pagamento">
                        <HeaderStyle HorizontalAlign="Center" Width="20%" />
                        <ItemStyle HorizontalAlign="Center" Width="20%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="SITUACAO" HeaderText="Situação">
                        <HeaderStyle HorizontalAlign="Center" Width="20%" />
                        <ItemStyle HorizontalAlign="Center" Width="20%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="NOSSO_NUMERO" HeaderText="Nosso Número ">
                        <HeaderStyle HorizontalAlign="Center" Width="30%" />
                        <ItemStyle HorizontalAlign="Center" Width="30%" />
                    </asp:BoundField>
                </Columns>
                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#808080" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#383838" />
            </asp:GridView>
        </div>
        <br />
        <asp:Panel ID="pnlAcoes" runat="server" Visible="false">
            <div class="legenda">
                <asp:Button ID="btnIncluir" runat="server" formnovalidate="formnovalidate" OnClick="btnIncluir_Click"
                    Text="Incluir" Visible="True" Width="100px" />
                &nbsp;<asp:Button ID="btnAtualizar" runat="server" formnovalidate="formnovalidate" 
                    OnClick="btnAtualizar_Click" Text="Atualizar" Visible="True" Width="100px" />
                &nbsp;<asp:Button ID="btnExcluir" runat="server" Text="Excluir" Visible="True" formnovalidate="formnovalidate"
                    OnClick="btnExcluir_Click" Width="100px" />
                &nbsp;<asp:Button ID="btnCancelar" runat="server" Text="Cancelar" formnovalidate="formnovalidate"
                    Visible="True" OnClick="btnCancelar_Click" Width="100px" />
            </div>
        </asp:Panel>
        <br />
    </asp:Panel>
    <br />
    <asp:Panel ID="pnlCadastro" runat="server" GroupingText="Atualizar Ficha Financeira"
        Visible="False">
        <table class="form-inline">
            <tr>
                <td>
                    Data de Vencimento
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txtDtVencimento" runat="server" MaxLength="10" Width="150px"></asp:TextBox>
                    <asp:CalendarExtender ID="calendarioDtVencimento" runat="server" Enabled="True" TargetControlID="txtDtVencimento">
                    </asp:CalendarExtender>
                </td>
            </tr>
            <tr>
                <td>
                    Valor
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txtValor" runat="server" onKeyPress="return(MascaraMoeda(this,'.',',',event))"
                        Width="150px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Situação
                </td>
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="ddlSituacao" runat="server" Width="150px">
                        <asp:ListItem Value="EM ABERTA">EM ABERTA</asp:ListItem>
                        <asp:ListItem Value="DISPENSADA">DISPENSADA</asp:ListItem>
                        <asp:ListItem Value="PAGO">PAGO</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
        </table>
        <br />
        <div class="legenda">
            <asp:Button ID="btnConfirmar" runat="server" Text="Confirmar" 
                OnClick="btnConfirmar_Click" Width="100px" />
            &nbsp;<asp:Button ID="btnCancelarCadastro" runat="server" Text="Cancelar" OnClick="btnCancelarCadastro_Click" />
        </div><br />
    </asp:Panel>
    <br />
    <asp:Panel ID="pnlParcelasRestantes" runat="server" GroupingText="Gerar Parcelas Restantes"
        Visible="False">
        <table class="form-inline">
            <tr>
                <td>
                    Data Primeiro Vencimento
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txtData1Vencimento" required runat="server" Height="30px" MaxLength="10"
                        Width="150px"></asp:TextBox>
                    <asp:CalendarExtender ID="CalendarExtender1" runat="server" Enabled="True" TargetControlID="txtData1Vencimento">
                    </asp:CalendarExtender>
                </td>
            </tr>
        </table>
        <br />
        <div class="legenda">
            <asp:Button ID="btnConfirmarGerar" runat="server" Text="Confirmar" OnClick="btnConfirmarGerar_Click" />
            &nbsp;<asp:Button ID="btnCancelarGerar" formnovalidate="formnovalidate" runat="server"
                Text="Cancelar" OnClick="btnCancelarGerar_Click" />
        </div><br />
    </asp:Panel>
</asp:Content>
